// Drummer
// by Andrea Bianchi
// andreabianchi.alsoplantsfly.com

/*
 Copyright (C) 2009, Andrea Bianchi
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


#ifndef __GLOBAL__H__
#define __GLOBAL__H__

// INCLUDES
#include <PA9.h>

// TYPEDEF
typedef u16 Color;

// DEFINES
#define WIDTH 255
#define HEIGHT 191
#define min(a,b) (((a)<(b))? (a):(b))
#define RGB(a,b,c) (PA_RGB( (((a)*(31))/(256)),(((b)*(31))/(256)),(((c)*(31))/(256)) ))

#define TEXT_LAYER 2
#define KEYBOARD_LAYER 1
#define GRAPHICS_LAYER 0 

// GLOBALS

static Color BLACK= 0;
static Color NONE= 0xFFFF;
static u8 NO_SELECTION= 0xFF;

// DATA STRUCTURES
enum ScreenId {LOWER_SCREEN, UPPER_SCREEN};

struct Coord
{	
	Coord():x_(0), y_(0){}
	Coord (u16 x, u16 y): x_(x), y_(y) {}
	Coord (const Coord& c){ x_=c.x_; y_=c.y_;}

	void setXY (u16 x, u16 y){ x_=x; y_=y;}
	bool operator==(const Coord& other)
	{
		return x_==other.x_ && y_==other.y_;
	}
	friend Coord operator+(const Coord& a, const Coord& b)
	{
		Coord ret;
		ret.x_=a.x_+b.x_;
		ret.y_=a.y_+b.y_;
		return ret;
	}
	
	friend Coord operator-(const Coord& a, const Coord& b)
	{
		Coord ret;
		ret.x_=a.x_-b.x_;
		ret.y_=a.y_-b.y_;
		return ret;
	}
		
	// members
	s16 x_,y_;
};

struct BoundingBox
{
	Coord s_, e_;
};

// Drum parts
enum Background {TITLE, IDLE, HIT, BASSDRUM, HIHAT, TOM, SNARE, CRASH};
enum DrumPart {SILENCE,
			   BASSDRUM1, BASSDRUM2,
			   HIHAT1, HIHAT2,
			   SNARE1, SNARE2,
			   CRASH1, CRASH2,
			   TOM1, TOM2, TOM3, TOM4};

#endif __GLOBAL__H__